require("should");

const { initMongoose } = require("../lib/init");

const { resolve } = require("path");

describe("test mongoose operation", () => {
	let obj = {};

	before(() => {
		initMongoose.call(obj, {
			schemaDefineRoot: resolve(__dirname, "../test/models/"),
			host: "192.168.137.119",
			port: "27017",
			database: "test"
		});
	});

	it("should has property `Test`", () => {
		obj.should.has.property("Test");
	});

	it("should return ok when create model data", () => {
		obj.Test.create({
			cn: "test_CN",
			en: "test_EN"
		}).then(model => {
			model.should.be.ok();
			model._id.should.be.ok();
		});
	});
});
